﻿// Copyright © Microsoft Corporation.  All Rights Reserved.
// This code released under the terms of the 
// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)

using System.Windows;
using System.Windows.Interactivity;

namespace Microsoft.Samples
{
    public class DragWindowBehavior : TargetedTriggerAction<FrameworkElement>
    {
        protected override void OnAttached()
        {
            FrameworkElement element = this.AssociatedObject as FrameworkElement;
            base.OnAttached();
        }

        protected override void Invoke(object o)
        {
            // Works only out-of-browser
            if (Application.Current.IsRunningOutOfBrowser 
                && Application.Current.HasElevatedPermissions)
            {
                Application.Current.MainWindow.DragMove();
            }
        }
    }
}
